import React from 'react';
import { connect } from 'dva';
import SLogin from '../components/Login';


class Login extends React.Component {
    componentDidMount() {
      // const { dispatch } = this.props;
      // dispatch({ type: 'layout/getCaptcha', payload: {} });
    }
    render() {
      const { dispatch, loading, captcha } = this.props;
      const loginProps = {
        loading,
        captcha,
        onLogin(data) {
          dispatch({ type: 'layout/login', payload: data });
        },
        getMsg(payload) {
          dispatch({ type: 'layout/getMsg', payload });
        },
        changeCaptcha() {
          dispatch({ type: 'layout/getCaptcha', payload: {} });
        }
      };
      return (<div>
        <SLogin {...loginProps} />
      </div>);
    }
  }
  
  const mapStateToProps = ({ layout }) => {
    return {
      ...layout
    };
  };
  
  export default connect(mapStateToProps)(Login);